package com.example.myapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.flutter.plugin.common.MethodChannel;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.button)
    Button lvButton;

    @BindView(R.id.textView)
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ButterKnife.bind(this);
        bindView();
    }

    protected void bindView() {
        lvButton.setOnClickListener(v -> {
            Intent intent = new Intent(this, FlutterActivity.class);
            // 参数（JSON数据）
            intent.putExtra("data", "{\"title\": \"Flutter 页面\"}");
            // 路由
            intent.putExtra("route", "");
            startActivityForResult(intent, 0);
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case 0:
                textView.setText(data == null ? "null" : data.getStringExtra("message"));
                break;
            default:
                break;
        }
    }
}
